package com.bigegg.employee.domain;


import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.utils.html.EscapeUtil;
import lombok.Data;

import java.util.Base64;

/**
 * 加密登录消息对象
 * @author sun
 */
@Data
public class EncodeSignInBody {

    private String userInfo;


    /**
     * 获取 SignInBody
     * 解析格式base64解码后json 反序列化
     *
     * @return SignInBody
     */
    public SignInBody getSignInBody() {
        SignInBody signInBody;
        try {
            assert userInfo != null;
            String jsonStr = EscapeUtil.decode(new String(Base64.getDecoder().decode(userInfo)));
            signInBody = JSON.parseObject(jsonStr, SignInBody.class);
        } catch (Exception e) {
            throw new RuntimeException("解析登录信息失败，请确数据保格式正确.");
        }
        return signInBody;
    }

}
